Socket
Socket
Sign inDemoInstall

bcp-47-normalize

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bcp-47-normalize

Normalize, canonicalize, and format BCP 47 tags


Version published
Weekly downloads
121K
increased by2.2%
Maintainers
1
Weekly downloads
 
Created
Source

bcp-47-normalize

Build Coverage Downloads Size

Normalize, canonicalize, and format BCP 47 tags.

Install

npm:

npm install bcp-47-normalize

Use

var normalize = require('bcp-47-normalize')

var tags = [
  'de-de-1901',
  'en-gb',
  'en-us',
  'en-bu',
  'hy-arevmda',
  'nld-nl',
  'no-nyn',
  'pt-br',
  'pt-pt',
  'zh-hans-cn'
]

tags.forEach(function(tag) {
  console.log('%s -> %s', tag, normalize(tag))
})

Yields:

de-de-1901 -> de-1901
en-gb -> en-GB
en-us -> en
en-bu -> en-MM
hy-arevmda -> hyw
nld-nl -> nl
no-nyn -> nn
pt-br -> pt
pt-pt -> pt-PT
zh-hans-cn -> zh-CN

API

normalize(tag[, options])

Normalize the given BCP 47 tag according to Unicode CLDR suggestions.

options.forgiving

Passed to bcp-47 as options.forgiving.

options.warning

Passed to bcp-47 as options.warning.

One additional warning is given:

codereason
7Deprecated region CURRENT, expected one of SUGGESTIONS

This warning is only given if the region cannot be automatically fixed (when regions split into multiple regions).

Returns

string — Normal, canonical, and pretty BCP 47 tag.

  • bcp-47 — Parse and stringify BCP 47 language tags
  • bcp-47-match — Match BCP 47 language tags with language ranges per RFC 4647
  • iso-3166 — ISO 3166 codes
  • iso-639-2 — ISO 639-2 codes
  • iso-639-3 — ISO 639-3 codes
  • iso-15924 — ISO 15924 codes
  • un-m49 — UN M49 codes

License

MIT © Titus Wormer

Keywords

FAQs

Package last updated on 26 Oct 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc